home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / libsrc~1.z / libsrc~1 / fungetc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-28  |  381 b   |  18 lines

  1. /* from dlibs */
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <sys/types.h>
  5. #include <unistd.h>
  6.  
  7. int fungetc(c, fp)
  8. int c;
  9. register FILE *fp;
  10. {
  11.     if((fp->_flag & (_IOERR | _IOEOF))    /* error or eof */
  12.        || (fp->_ptr <= fp->_base)        /* or too many ungets */
  13.        || (c < 0))                /* or trying to unget EOF */
  14.     return(EOF);
  15.     ++(fp->_cnt);
  16.     return(*--(fp->_ptr) = c);
  17. }
  18.